import request from '@/utils/request'

export function fetchAllVotes(teamId, page, per_page) {
  return request({
    url: '/votes',
    params: { page, per_page },
    method: 'get'
  })
}

export function publishVote(vote) {
  return request({
    url: '/votes',
    method: 'post',
    data: { ...vote }
  })
}

export function fetchVote(id) {
  return request({
    url: '/votes/' + id,
    method: 'get'
  })
}

export function fetchBucket(id) {
  return request({
    url: '/votes/' + id + '/buckets',
    method: 'get'
  })
}

export function createBucket(id, data) {
  return request({
    url: '/votes/' + id + '/buckets',
    method: 'post',
    data: { data }
  })
}

export function fetchResult(id) {
  return request({
    url: '/votes/' + id + '/results',
    method: 'get'
  })
}

export function fetchAllBuckets(id) {
  return request({
    url: '/votes/' + id + '/allbuckets',
    method: 'get'
  })
}
